#include <iostream>

using namespace std;
//string子串:从字符串中获取想要的子串
//函数原型：
//string substr(int pos = 0, int n = npos) const;   //返回由pos开始的n个字符组成的字符串

void test1() {
    string s = "abcdfghijklmn";
    string s1 = s.substr(1, 3);
    cout << "s1:" << s1 << endl;
}

void test2() {
    string email = "zhangshan@sina.com";
    //从邮件地址中截取用户信息
    int pos = email.find('@');
    string name = email.substr(0, pos);
    cout << "name:" << name << endl;
}

int main() {
    test1();
    test2();
    return 0;
}